<%--
  Created by IntelliJ IDEA.
  User: sunhao
  Date: 2016/4/7 0007
  Time: 13:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
<head>
    <title>添加新闻</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/static/bui/css/bs3/dpl.css" rel="stylesheet" type="text/css"/>
    <link href="/static/bui/css/bs3/bui.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" src="/static/bui/js/jquery-1.8.1.min.js"></script>
</head>
<body>
<div class="content" style="margin: 15px">

    <form id="J_Form" class="form-horizontal" style="outline: none;width: 1100px" action="/news/edit"
          method="post">

        <input type="hidden" name="id" value="${news._id}">

        <div class="row">
            <div class="control-group span14">
                <label class="control-label"><s>*</s>文章标题</label>

                <div class="controls">
                    <input name="title" type="text" data-rules="{required:true}"
                           class="input-large control-text" value="${news.title}">
                </div>
            </div>

            <div class="control-group span8">
                <label class="control-label"><s>*</s>作者</label>

                <div class="controls">
                    <input name="auth" type="text" data-rules="{required:true}"
                           class="input control-text" value="${news.auth}">
                </div>
            </div>


        </div>
        <div class="row">
            <div class="control-group span14">
                <label class="control-label"><s>*</s>文章描述</label>

                <div class="controls">
                    <input name="info" type="text" data-rules="{required:true}"
                           class="input-large control-text" value="${news.info}">
                </div>
            </div>
            <div class="control-group span8">
                <label class="control-label"><s>*</s>状态：</label>

                <div class="controls control-row2">
                    <select name="status">
                        <option value="0" <c:if test="${news.status==0}"> selected</c:if> >常规</option>
                        <option value="1" <c:if test="${news.status==1}"> selected</c:if> >置顶一</option>
                        <option value="2" <c:if test="${news.status==2}"> selected</c:if> >置顶二</option>
                        <option value="3" <c:if test="${news.status==3}"> selected</c:if> >置顶三</option>
                        <option value="-1" <c:if test="${news.status==-1}"> selected</c:if> >下线</option>
                    </select>
                </div>
            </div>
            <div class="row">
                <div class="control-group span8">
                    <label class="control-label"><s>*</s>类型：</label>

                    <div class="controls control-row2">
                        <select name="type">
                            <option value="1" <c:if test="${news.type==1}"> selected</c:if> >新闻</option>
                            <option value="2" <c:if test="${news.type==2}"> selected</c:if> >活动</option>
                        </select>
                    </div>
                </div>
            <div class="control-group span4" style="float: right;margin-bottom: 20px">
                <button id="btnSearch" type="submit" class="button button-primary" style="margin-top: 20px">提交</button>
            </div>
            </div>
        </div>


        <div class="row" style="margin: 0 auto">
            <div id="valueContent" style="display: none">${news.content}</div>
            <div class="control-group span12">
                <!-- 加载编辑器的容器 -->
                <div>
                    <script id="container" name="content" type="text/plain" style="width:1024px;height:500px;">
                    </script>
                </div>
            </div>

        </div>
    </form>
</div>
<script type="text/javascript">

    // 定义UEditor对应的主目录
    window.UEDITOR_HOME_URL = "${contextPath}/ueditor/";
    // 页面加载完成后载入UEditor
    window.onload = function () {
        window.UEDITOR_CONFIG.initialFrameWidth = 950;
        window.UEDITOR_CONFIG.initialFrameHeight = 600;
        var editor = UE.getEditor('container');

        UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
        UE.Editor.prototype.getActionUrl = function (action) {
            if (action == "uploadimage") {
                return "/uploadImage.json";
            } else if (action == "uploadvideo") {
                return "/uploadVideo.json"
            }
            else {
                return this._bkGetActionUrl.call(this, action);
            }
        }

        var content = $('#valueContent').html()
//        console.log(content)
        $(function () {
            //判断ueditor 编辑器是否创建成功
            editor.addListener("ready", function () {
                // editor准备好之后才可以使用
                editor.setContent(content);
            });
        });
    }
</script>
</body>
</html>
